<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
?>
<!-- JavaScript -->
<script type="text/javascript" src="<?= base_url() ?>js/wufoo.js"></script>
<script src="<?= base_url() ?>js/chosen.jquery.js" type="text/javascript"></script>
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="<?= base_url() ?>css/form/form.css" media="screen, tv, projection" title="Default" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>css/datepicker.css" media="screen, tv, projection" title="Default" />
<script type="text/javascript" src="<?= base_url() ?>js/datepicker.js"></script>
<link rel="stylesheet" href="<?php echo base_url() ?>css/chosen.css" />

<div id="container">
	<?
    //Setting Awal Value Jika Prosedur yang dilakukan adalah prosedur input biasa.
		$value['legend'] = "Form Pencarian Data";
		$value['info'] = "Form untuk melakukan pencarian daftar data dalam aplikasi";
		$value['act_form'] = "pencarian_grid/form_pencarian_grid";
	//end if
	
	?>
	<?= form_open($value["act_form"],'class="wufoo" name="form_pencarian_grid"'); ?>
	
	<fieldset class="fieldset">
	<legend class="legend">
		<?= $value["legend"] ?> |
	</legend>
	
	<div class="info">
		<div><?= $value["info"] ?></div>
	</div>
	<div>
		<?= anchor(site_url(''),img(array('src'=>'images/main/38.png','border'=>'0','alt'=>'')).' Kembali ke menu utama','Menampilkan halaman menu utama'); ?>
	</div>
 <!-- Konten -------------------------------------------------------------------------->
 
 <div id="contentform">
 
 	<ul>
	    <li>
		<label class="desc">Pilih Data Pencarian *</label>
		<div>
		    <input type="radio" name="pencarian" value="1" onChange="combo_active()"/>Daftar program berdasarkan tahun anggaran<br />
		    <input type="radio" name="pencarian" value="2" onChange="combo_active()"/>Daftar kegiatan berdasarkan tahun anggaran dan program<br />
		    <input type="radio" name="pencarian" value="3" onChange="combo_active()"/>Daftar sasaran strategis (program) berdasarkan tahun anggaran dan program<br />
		    <input type="radio" name="pencarian" value="4" onChange="combo_active()"/>Daftar sasaran strategis (kegiatan) berdasarkan tahun anggaran, program dan kegiatan<br />
		    <input type="radio" name="pencarian" value="5" onChange="combo_active()"/>Daftar indikator kinerja (program) berdasarkan tahun anggaran, program dan sasaran strategis (program)<br />
		    <input type="radio" name="pencarian" value="6" onChange="combo_active()"/>Daftar indikator kinerja (kegiatan) berdasarkan tahun anggaran, program, kegiatan dan sasaran strategis (kegiatan)
		</div>
	    </li>
	</ul> 
    
	<ul>
		
		<li>
		    <label class="desc">Pilih Tahun Anggaran *</label>
			<div>
				 <? 
				 //list tahun
				 echo form_dropdown('tahun',$options_anggaran,NULL,'onChange="get_program()" id="tahun"');	
				 ?>
			</div>				      
                    <p class="instruct">
                            Pilih Tahun Anggaran Pada Kolom ini.			
                    </p>
                </li>

                <?php echo form_error('tahun'); ?>
		
		
		<li>
                    <label class="desc">Program</label>
                        <div>
                        <select id="program" name="program" disabled="disabled" onchange="get_sasaran_prog(),get_kegiatan(), get_indikator_prog(), get_sasaran_keg(),get_indikator_keg()">
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Program Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('program'); ?>
		
		<li>
                    <label class="desc">Sasaran Strategis (Program)</label>
                        <div>
                        <select id="sasaran_prog" name="sasaran_prog" disabled="disabled" onchange="get_indikator_prog()">
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Sasaran Strategis (Program) Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('sasaran_prog'); ?>
			
		<li>
                    <label class="desc">Kegiatan</label>
                        <div>
                        <select id="kegiatan" name="kegiatan" disabled="disabled" onchange="get_sasaran_keg(),get_indikator_keg()">
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Kegiatan Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('kegitan'); ?>
		
		<li>
                    <label class="desc">Sasaran Strategis (Kegiatan)</label>
                        <div>
                        <select id="sasaran_keg" name="sasaran_keg" disabled="disabled" onchange="get_indikator_keg()">
                        <option value="0">-- Pilih Semua --</option>
                      </select>
                        </div>
                    <p class="instruct">
                            Pilih Sasaran Strategis (Kegiatan) Pada Kolom ini.			
                    </p>
                </li>
                <?php echo form_error('sasaran_keg'); ?>
		
		<li class="buttons">
		  <input id="saveForm" class="btTxt" type="submit" value="Cari" />
		  <input name="submit" type="reset" value="Batal" />
		</li>
	</ul>
</div>
</fieldset>
<?= form_close(); ?>
</form>
</div><!--container-->

<script type="text/javascript">
  $(".chzn-select").chosen();
  $(".chzn-select-deselect").chosen({allow_single_deselect:true});
</script>

<script>

function combo_active(){
    
    var program = document.form_pencarian_grid.pencarian[0];
    var kegiatan = document.form_pencarian_grid.pencarian[1];
    var sasaran_program = document.form_pencarian_grid.pencarian[2];
    var sasaran_kegiatan = document.form_pencarian_grid.pencarian[3];
    var indikator_program = document.form_pencarian_grid.pencarian[4];
    var indikator_kegiatan = document.form_pencarian_grid.pencarian[5];
    
    if(program.checked == true){
	document.getElementById("program").disabled = true;
	document.getElementById("kegiatan").disabled = true;
	document.getElementById("sasaran_prog").disabled = true;
	document.getElementById("sasaran_keg").disabled = true;
    }else if(kegiatan.checked == true){
	document.getElementById("program").disabled = false;
	document.getElementById("kegiatan").disabled = true;
	document.getElementById("sasaran_prog").disabled = true;
	document.getElementById("sasaran_keg").disabled = true;
    }else if(sasaran_program.checked == true){
	document.getElementById("program").disabled = false;
	document.getElementById("sasaran_prog").disabled = true;
	document.getElementById("kegiatan").disabled = true;
	document.getElementById("sasaran_keg").disabled = true;
    }else if(sasaran_kegiatan.checked == true){
	document.getElementById("program").disabled = false;
	document.getElementById("kegiatan").disabled = false;
	document.getElementById("sasaran_keg").disabled = true;
	document.getElementById("sasaran_prog").disabled = true;
    }else if(indikator_program.checked == true){
	document.getElementById("program").disabled = false;
	document.getElementById("kegiatan").disabled = true;
	document.getElementById("sasaran_prog").disabled = false;
	document.getElementById("indikator_prog").disabled = true;
	document.getElementById("sasaran_keg").disabled = true;
    }else if(indikator_kegiatan.checked == true){
	document.getElementById("program").disabled = false;
	document.getElementById("kegiatan").disabled = false;
	document.getElementById("sasaran_keg").disabled = false;
	document.getElementById("sasaran_prog").disabled = true;
    }
    
}

function get_program(){
    var tahun = $("#tahun").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian_grid/get_program/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "tahun="+tahun, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)
						if ( dynamic_options != (-1)) $(".dynamic").remove();
                    $("#program").html(response);
                    $(".first").attr({selected: ' selected'});
					
                   }
                   
	});
	return false
}

function get_sasaran_prog(){
    var program = $("#program").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian_grid/get_sasaran_program/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "program="+program, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)	
                    $("#sasaran_prog").html(response);
                    $(".first").attr({selected: ' selected'});
                   }                
	});
	return false
}

function get_kegiatan(){
    var program = $("#program").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian_grid/get_kegiatan/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "program="+program, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)	
                    $("#kegiatan").html(response);
                    $(".first").attr({selected: ' selected'});
                   }              
	});
	return false
}
function get_sasaran_keg(){
    var kegiatan = $("#kegiatan").val();
	$.ajax({
        url: "<?=base_url();?>index.php/pencarian_grid/get_sasaran_keg/",
        global: false,
        type: "POST",
        async: false,
        dataType: "html",
        data: "kegiatan="+kegiatan, //the name of the $_POST variable and its value
        success: function (response) //'response' is the output provided by the controller method prova()
        {
                       //counts the number of dynamically generated options
                       var dynamic_options = $("*").index( $('.dynamic')[0] );
                    //removes previously dynamically generated options if they exists (not equal to 0)	
                    $("#sasaran_keg").html(response);
                    $(".first").attr({selected: ' selected'});
                   }                
	});
	return false
}
</script>